<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width">

<script src="//cdn.bootcss.com/pace/1.0.2/pace.min.js"></script>
<link href="//cdn.bootcss.com/pace/1.0.2/themes/pink/pace-theme-flash.css" rel="stylesheet">
<meta name="theme-color" content="#fff">
<meta name="generator" content="Hexo 5.4.0">

  <link rel="apple-touch-icon" sizes="180x180" href="/images/favicon.ico">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon.ico">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon.ico">
  <link rel="mask-icon" href="/images/logo.svg" color="#fff">

<link rel="stylesheet" href="/css/main.css">

<link rel="stylesheet" href="https://fonts.cat.net/css?family=Lato:300,300italic,400,400italic,700,700italic%7CRoboto+Slab:300,300italic,400,400italic,700,700italic%7CDejaVu+Sans+Mono:300,300italic,400,400italic,700,700italic&display=swap&subset=latin,latin-ext">

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5.15.3/css/all.min.css" integrity="sha256-2H3fkXt6FEmrReK448mDVGKb3WW2ZZw35gI7vqHOE4Y=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/animate.css@3.1.1/animate.min.css" integrity="sha256-PR7ttpcvz8qrF57fur/yAx1qXMFJeJFiA6pSzWi0OIE=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/nprogress@0.2.0/nprogress.css" integrity="sha256-no0c5ccDODBwp+9hSmV5VvPpKwHCpbVzXHexIkupM6U=" crossorigin="anonymous">
  <script src="https://cdn.jsdelivr.net/npm/nprogress@0.2.0/nprogress.js" integrity="sha256-a5YRB27CcBwBFcT5EF/f3E4vzIqyHrSR878nseNYw64=" crossorigin="anonymous"></script>

<script class="next-config" data-name="main" type="application/json">{"hostname":"hyw-zero.github.io","root":"/","images":"/images","scheme":"Gemini","version":"8.7.0","exturl":false,"sidebar":{"position":"left","display":"hide","padding":10,"offset":12,"scrollpercent":false,"onmobile":false},"copycode":true,"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"fadeInDown","post_body":"fadeInDown","coll_header":"fadeInLeft","sidebar":"fadeInUp"}},"prism":false,"i18n":{"placeholder":"搜索...","empty":"没有找到任何搜索结果：${query}","hits_time":"找到 ${hits} 个搜索结果（用时 ${time} 毫秒）","hits":"找到 ${hits} 个搜索结果"},"path":"/search.xml","localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false}}</script><script src="/js/config.js"></script>
<meta name="description" content="下述内容为个人学习笔记及查询资料总结，跳跃性较大，仅供参考。  1.项目介绍在使用Qt向导生成的应用程序.pro文件格式如下：">
<meta property="og:type" content="article">
<meta property="og:title" content="Qt学习笔记之信号与槽">
<meta property="og:url" content="https://hyw-zero.github.io/2019/01/06/Qt%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0%E4%B9%8B%E4%BF%A1%E5%8F%B7%E4%B8%8E%E6%A7%BD/index.html">
<meta property="og:site_name" content="ZERO">
<meta property="og:description" content="下述内容为个人学习笔记及查询资料总结，跳跃性较大，仅供参考。  1.项目介绍在使用Qt向导生成的应用程序.pro文件格式如下：">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://gitee.com/hyw-zero/blogimage/raw/master/img/lambda.png">
<meta property="article:published_time" content="2019-01-05T22:10:30.000Z">
<meta property="article:modified_time" content="2021-08-22T09:52:37.959Z">
<meta property="article:author" content="hyw-zero">
<meta property="article:tag" content="C++">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://gitee.com/hyw-zero/blogimage/raw/master/img/lambda.png">


<link rel="canonical" href="https://hyw-zero.github.io/2019/01/06/Qt%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0%E4%B9%8B%E4%BF%A1%E5%8F%B7%E4%B8%8E%E6%A7%BD/">



<script class="next-config" data-name="page" type="application/json">{"sidebar":"","isHome":false,"isPost":true,"lang":"zh-CN","comments":true,"permalink":"https://hyw-zero.github.io/2019/01/06/Qt%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0%E4%B9%8B%E4%BF%A1%E5%8F%B7%E4%B8%8E%E6%A7%BD/","path":"2019/01/06/Qt学习笔记之信号与槽/","title":"Qt学习笔记之信号与槽"}</script>

<script class="next-config" data-name="calendar" type="application/json">""</script>
<title>Qt学习笔记之信号与槽 | ZERO</title>
  



<script src="https://cdn.jsdelivr.net/gh/stevenjoezhang/live2d-widget@latest/autoload.js"></script>

  <noscript>
    <link rel="stylesheet" href="/css/noscript.css">
  </noscript>
<link rel="alternate" href="/atom.xml" title="ZERO" type="application/atom+xml">
</head>

<body itemscope itemtype="http://schema.org/WebPage" class="use-motion">
  <div class="headband"></div>
  <main class="main">
    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏" role="button">
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <i class="logo-line"></i>
      <h1 class="site-title">ZERO</h1>
      <i class="logo-line"></i>
    </a>
      <p class="site-subtitle" itemprop="description">keep  learning, be  curious !</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>



<nav class="site-nav">
  <ul class="main-menu menu">
        <li class="menu-item menu-item-home"><a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a></li>
        <li class="menu-item menu-item-about"><a href="/about/" rel="section"><i class="fa fa-user fa-fw"></i>关于</a></li>
        <li class="menu-item menu-item-tags"><a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签</a></li>
        <li class="menu-item menu-item-categories"><a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类</a></li>
        <li class="menu-item menu-item-archives"><a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a></li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup"><div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off" maxlength="80"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close" role="button">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div class="search-result-container no-result">
  <div class="search-result-icon">
    <i class="fa fa-spinner fa-pulse fa-5x"></i>
  </div>
</div>

    </div>
  </div>

</div>
        
  
  <div class="toggle sidebar-toggle" role="button">
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
  </div>

  <aside class="sidebar">

    <div class="sidebar-inner sidebar-nav-active sidebar-toc-active">
      
      <ul class="sidebar-nav">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <div class="sidebar-panel-container">
        <!--noindex-->
        <div class="post-toc-wrap sidebar-panel">
            <div class="post-toc animated"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-%E9%A1%B9%E7%9B%AE%E4%BB%8B%E7%BB%8D"><span class="nav-text">1.项目介绍</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-Qt%E5%BA%94%E7%94%A8%E7%A8%8B%E5%BA%8F%E4%BB%8B%E7%BB%8D"><span class="nav-text">2.Qt应用程序介绍</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#3-%E4%BF%A1%E5%8F%B7%E4%B8%8E%E6%A7%BD%E6%9C%BA%E5%88%B6-%E2%98%85%E2%98%85"><span class="nav-text">3.信号与槽机制  ★★</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#3-1-%E4%BF%A1%E5%8F%B7%E5%92%8C%E6%A7%BD"><span class="nav-text">3.1 信号和槽</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3-2-%E4%BF%A1%E5%8F%B7%E4%B8%8E%E6%A7%BD%E5%B8%B8%E8%A7%84%E5%86%99%E6%B3%95"><span class="nav-text">3.2 信号与槽常规写法</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3-3-%E8%87%AA%E5%AE%9A%E4%B9%89%E4%BF%A1%E5%8F%B7%E4%B8%8E%E6%A7%BD"><span class="nav-text">3.3 自定义信号与槽</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3-3-%E8%87%AA%E5%AE%9A%E4%B9%89%E4%BF%A1%E5%8F%B7%E4%B8%8E%E6%A7%BD-%E6%9C%89%E5%8F%82%E6%95%B0"><span class="nav-text">3.3 自定义信号与槽(有参数)</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3-4-%E8%87%AA%E5%AE%9A%E4%B9%89%E4%BF%A1%E5%8F%B7%E4%B8%8E%E6%A7%BD-%E6%9C%89%E5%8F%82%E6%95%B0%EF%BC%8C%E5%87%BD%E6%95%B0%E9%87%8D%E8%BD%BD"><span class="nav-text">3.4 自定义信号与槽(有参数，函数重载)</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3-5-Lambda%E8%A1%A8%E8%BE%BE%E5%BC%8F-%E2%98%85%E2%98%85%E2%98%85"><span class="nav-text">3.5 Lambda表达式  ★★★</span></a></li></ol></li></ol></div>
        </div>
        <!--/noindex-->

        <div class="site-overview-wrap sidebar-panel">
            <div class="site-overview">
              <div class="site-author site-overview-item animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="hyw-zero"
      src="/images/avatar.jpg">
  <p class="site-author-name" itemprop="name">hyw-zero</p>
  <div class="site-description" itemprop="description"></div>
</div>
<div class="site-state-wrap site-overview-item animated">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
        <a href="/archives/">
          <span class="site-state-item-count">13</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
          <a href="/categories/">
        <span class="site-state-item-count">5</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
          <a href="/tags/">
        <span class="site-state-item-count">4</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author site-overview-item animated">
      <span class="links-of-author-item">
        <a href="mailto:hyw33666@gmail.com" title="E-Mail → mailto:hyw33666@gmail.com" rel="noopener" target="_blank"><i class="fa fa-envelope fa-fw"></i>E-Mail</a>
      </span>
      <span class="links-of-author-item">
        <a href="https://github.com/hyw-zero" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;hyw-zero" rel="noopener" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
      </span>
  </div>


  <div class="links-of-blogroll site-overview-item animated">
    <div class="links-of-blogroll-title"><i class="fa fa-link fa-fw"></i>
      推荐阅读
    </div>
    <ul class="links-of-blogroll-list">
        <li class="links-of-blogroll-item">
          <a href="http://c.biancheng.net/cplus/" title="http:&#x2F;&#x2F;c.biancheng.net&#x2F;cplus&#x2F;" rel="noopener" target="_blank">c语言中文网</a>
        </li>
        <li class="links-of-blogroll-item">
          <a href="https://github.com/chenshuo/documents/downloads" title="https:&#x2F;&#x2F;github.com&#x2F;chenshuo&#x2F;documents&#x2F;downloads" rel="noopener" target="_blank">Linux多线程服务端</a>
        </li>
        <li class="links-of-blogroll-item">
          <a href="https://github.com/SilverMaple/STLSourceCodeNote" title="https:&#x2F;&#x2F;github.com&#x2F;SilverMaple&#x2F;STLSourceCodeNote" rel="noopener" target="_blank">STL源码剖析</a>
        </li>
    </ul>
  </div>
<div class="cc-license animated" itemprop="sponsor">
  <a href="https://www.netlify.com" class="cc-opacity" title="Deploy with Netlify → https://www.netlify.com" target="_blank"><img width="80" src="https://www.netlify.com/img/global/badges/netlify-dark.svg" alt="Netlify"></a>
</div>
            </div>
        </div>
	    </div>
	  

    </div>
	<iframe frameborder="no" border="0" marginwidth="0" marginheight="0" width=280 height=300 src="//music.163.com/outchain/player?type=0&id=411680085&auto=1&height=430"></iframe>
  <div class="sidebar-dimmer"></div>


    </header>

    
  <div class="back-to-top" role="button" aria-label="返回顶部">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>
  <div class="reading-progress-bar"></div>

<noscript>
  <div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>


    <div class="main-inner post posts-expand">


  


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://hyw-zero.github.io/2019/01/06/Qt%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0%E4%B9%8B%E4%BF%A1%E5%8F%B7%E4%B8%8E%E6%A7%BD/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.jpg">
      <meta itemprop="name" content="hyw-zero">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="ZERO">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          Qt学习笔记之信号与槽
        </h1>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>

      <time title="创建时间：2019-01-05 22:10:30" itemprop="dateCreated datePublished" datetime="2019-01-05T22:10:30Z">2019-01-05</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">分类于</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/Qt%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/" itemprop="url" rel="index"><span itemprop="name">Qt学习笔记</span></a>
        </span>
    </span>

  
    <span class="post-meta-item" title="阅读次数" id="busuanzi_container_page_pv">
      <span class="post-meta-item-icon">
        <i class="far fa-eye"></i>
      </span>
      <span class="post-meta-item-text">阅读次数：</span>
      <span id="busuanzi_value_page_pv"></span>
    </span>
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">
        <blockquote>
<p>下述内容为个人学习笔记及查询资料总结，跳跃性较大，仅供参考。</p>
</blockquote>
<h2 id="1-项目介绍"><a href="#1-项目介绍" class="headerlink" title="1.项目介绍"></a>1.项目介绍</h2><p>在使用Qt向导生成的应用程序.pro文件格式如下：</p>
<span id="more"></span> 

<figure class="highlight properties"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">QT</span> <span class="string">+= core gui  //模块的名字</span></span><br><span class="line"></span><br><span class="line"><span class="meta">greaterThan(QT_MAJOR_VERSION,</span> <span class="string">4): QT += widgets</span></span><br><span class="line"></span><br><span class="line"><span class="attr">TARGET</span> = <span class="string">test //应用程序名</span></span><br><span class="line"></span><br><span class="line"><span class="attr">TEMPLATE</span> = <span class="string">app //生成的makefile的模板类型</span></span><br><span class="line"></span><br><span class="line"><span class="attr">//源文件</span></span><br><span class="line"><span class="attr">SOURCES</span> <span class="string">+= main.cpp\</span></span><br><span class="line"><span class="string">			 mainwindow.cpp</span></span><br><span class="line"> <span class="attr">//头文件</span></span><br><span class="line"><span class="attr">HEADERS</span> <span class="string">+= mainwindow.h</span></span><br><span class="line"></span><br><span class="line"><span class="attr">//窗口设计文件</span></span><br><span class="line"><span class="attr">FORMS</span>  <span class="string">+= mainwindow.ui</span></span><br></pre></td></tr></table></figure>

<p><strong>源文件中以.pro为结尾的就是工程文件(project)，它是qmake自动生成的用于生产makefile的配置文件</strong></p>
<p><strong>pro文件的写法如下：</strong></p>
<ul>
<li><p>注释</p>
<p>​    从“#”开始，到这一行结束。</p>
</li>
<li><p>模板变量告诉qmake为这个应用程序生成哪种makefile。下面是可供使用的</p>
<p>选择：<strong>TEMPLATE</strong> =app</p>
<ul>
<li><p><strong>app</strong> -建立一个应用程序的makefile。这是默认值，所以如果模板没有被指定，这个将被使用。</p>
</li>
<li><p><strong>lib</strong> - 建立一个库的makefile。</p>
</li>
<li><p><strong>vcapp</strong> - 建立一个应用程序的VisualStudio项目文件。</p>
</li>
<li><p><strong>vclib</strong> - 建立一个库的VisualStudio项目文件。</p>
</li>
<li><p><strong>subdirs</strong> -这是一个特殊的模板，它可以创建一个能够进入特定目录并且为一个项目文件生成makefile并且为它调用make的makefile。</p>
</li>
</ul>
</li>
<li><p>#指定生成的应用程序名： </p>
<p><strong>TARGET</strong> = QtDemo</p>
</li>
<li><p>#工程中包含的头文件</p>
<p><strong>HEADERS</strong> += include/painter.h</p>
</li>
<li><p>#工程中包含的.ui设计文件</p>
<p><strong>FORMS</strong> += forms/painter.ui</p>
</li>
<li><p>#工程中包含的源文件</p>
<p><strong>SOURCES</strong> += sources/main.cpp sources/painter.cpp</p>
</li>
<li><p>#工程中包含的资源文件</p>
<p><strong>RESOURCES</strong> += qrc/painter.qrc</p>
</li>
<li><p><strong>greaterThan(QT_MAJOR_VERSION, 4): QT += widgets</strong></p>
<p>这条语句的含义是，如果QT_MAJOR_VERSION大于4（也就是当前使用的Qt5及更高版本）需要增加widgets模块。如果项目仅需支持Qt5，也可以直接添加“QT += widgets”一句。不过为了保持代码兼容，最好还是按照QtCreator生成的语句编写。</p>
</li>
<li><p>#配置信息<br>CONFIG用来告诉qmake关于应用程序的配置信息。<br><strong>CONFIG += c++11  //使用c++11的特性</strong><br>在这里使用“+=”，是因为我们添加我们的配置选项到任何一个已经存在中。这样做比使用“=”那样替换已经指定的所有选项更安全。</p>
<blockquote>
<p>一般在Qt源文件中以**.pro.user**为结尾为用户配置文件，需要使用此项目时，最好删除掉。编译后会重新创建。</p>
</blockquote>
</li>
</ul>
<h2 id="2-Qt应用程序介绍"><a href="#2-Qt应用程序介绍" class="headerlink" title="2.Qt应用程序介绍"></a>2.Qt应用程序介绍</h2><figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;QApplication&gt;</span>  <span class="comment">//QApplication应用程序类</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;QWidget&gt;</span></span></span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">(<span class="keyword">int</span> argc, <span class="keyword">char</span> *argv[])</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	<span class="function">QApplication <span class="title">a</span><span class="params">(argc, argv)</span></span>;</span><br><span class="line">	QWidget w;</span><br><span class="line">	w.<span class="built_in">show</span>();</span><br><span class="line">	<span class="keyword">return</span> a.<span class="built_in">exec</span>();</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p><strong>解释：</strong></p>
<ul>
<li><p>Qt头文件没有.h后缀</p>
</li>
<li><p>Qt一个类对应一个头文件，类名就是头文件名</p>
</li>
<li><p>QApplication应用程序类</p>
<ul>
<li>管理图形用户界面应用程序的控制流和主要设置。</li>
<li>是Qt的整个后台管理的命脉它<strong>包含主事件循环</strong>，在其中来自窗口系统和其它资源的<strong>所有事件处理和调度</strong>。它也处理<strong>应用程序的初始化和结束</strong>，并且<strong>提供对话管理</strong>。</li>
<li>对于任何一个使用Qt的图形用户界面应用程序，都正好存在一个QApplication 对象，而不论这个应用程序在同一时间内是不是有0、1、2或更多个窗口。</li>
</ul>
</li>
<li><p>a.exec()</p>
<p>程序进入消息循环，等待对用户输入进行响应。这里main()把控制权转交给Qt，Qt完成事件处理工作，当应用程序退出的时候exec()的值就会返回。</p>
<p><strong>在exec()中，Qt接受并处理用户和系统的事件并且把它们传递给适当的窗口部件。</strong></p>
<blockquote>
<p>在创建项目后，最好不要修改主函数，建议在主窗口文件的构造函数中进行代码创建。</p>
</blockquote>
</li>
</ul>
<h2 id="3-信号与槽机制-★★"><a href="#3-信号与槽机制-★★" class="headerlink" title="3.信号与槽机制  ★★"></a>3.信号与槽机制  ★★</h2><p>​        所谓信号与槽，实际就是观察者模式。<strong>当某个事件发生之后</strong>，比如，按钮检测到自己被点击了一下，<strong>它就会发出一个信号（signal）</strong>。这种发出是没有目的的，类似广播。<strong>如果有对象对这个信号感兴趣，它就会使用连接（connect）函数</strong>，意思是，<strong>将想要处理的信号和自己的一个函数（称为槽（slot））绑定来处理这个信号</strong>。也就是说，<strong>当信号发出时，被连接的槽函数会自动被回调</strong>。这就类似观察者模式：当发生了感兴趣的事件，某一个操作就会被自动触发。</p>
<h3 id="3-1-信号和槽"><a href="#3-1-信号和槽" class="headerlink" title="3.1 信号和槽"></a>3.1 信号和槽</h3><p>使用connect()可以让我们连接系统提供的信号和槽。connect()函数最常用的一般形式：</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">connect</span>(sender, signal, receiver, slot);</span><br></pre></td></tr></table></figure>

<p><strong>参数：</strong></p>
<ul>
<li>sender：发出信号的对象</li>
<li> signal：发送对象发出的信号</li>
<li> receiver：接收信号的对象</li>
<li> slot：接收对象在接收到信号之后所需要调用的函数</li>
</ul>
<p><strong>信号槽要求信号和槽的参数一致，所谓一致，是参数类型一致。如果不一致，允许的情况是，槽函数的参数可以比信号的少，即便如此，槽函数存在的那些参数的顺序也必须和信号的前面几个一致起来。这是因为，你可以在槽函数中选择忽略信号传来的数据（也就是槽函数的参数比信号的少），但是不能说信号根本没有这个数据，你就要在槽函数中使用（就是槽函数的参数比信号的多，这是不允许的）。</strong></p>
<h3 id="3-2-信号与槽常规写法"><a href="#3-2-信号与槽常规写法" class="headerlink" title="3.2 信号与槽常规写法"></a>3.2 信号与槽常规写法</h3><p>使用系统提供的信号与槽函数</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">QPushButton b1;</span><br><span class="line">b1.<span class="built_in">setParent</span>(<span class="keyword">this</span>);</span><br><span class="line"><span class="built_in">connect</span>(&amp;b1,&amp;QPushButton::pressed,<span class="keyword">this</span>,&amp;MainWidget::close);</span><br><span class="line"> <span class="comment">/*</span></span><br><span class="line"><span class="comment">  *    &amp;b1                      信号发出者</span></span><br><span class="line"><span class="comment">  *    &amp;QPushButton::pressed    处理的信号,&amp;发送者类名::动作</span></span><br><span class="line"><span class="comment">  *    this                     信号接收者</span></span><br><span class="line"><span class="comment">  *    &amp;MainWidget::close       槽函数-信号处理函数,&amp;接收者类名::槽函数类名</span></span><br><span class="line"><span class="comment">  */</span></span><br></pre></td></tr></table></figure>

<h3 id="3-3-自定义信号与槽"><a href="#3-3-自定义信号与槽" class="headerlink" title="3.3 自定义信号与槽"></a>3.3 自定义信号与槽</h3><p>Qt 的信号槽机制并不仅仅是使用系统提供的那部分，还会允许我们自己设计自己的信号和槽。</p>
<p><strong>1.自定义信号与槽(无参数)</strong></p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/*</span></span><br><span class="line"><span class="comment">   * 自定义信号必须有signals 关键字来声明</span></span><br><span class="line"><span class="comment">   * 信号没有返回值，但可以有参数</span></span><br><span class="line"><span class="comment">   * 信号就是函数的声明，只需声明，无需定义</span></span><br><span class="line"><span class="comment">   * 使用：emit mysigna1（）；</span></span><br><span class="line"><span class="comment">*/</span></span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">subwidget</span>:</span>: <span class="keyword">public</span> QWidget</span><br><span class="line">&#123;</span><br><span class="line">  Q_OBJECT</span><br><span class="line"><span class="keyword">public</span>:</span><br><span class="line">  <span class="function"><span class="keyword">explicit</span> <span class="title">SubWidget</span><span class="params">(QWidget *parent = <span class="number">0</span>)</span></span>;</span><br><span class="line">signals：      <span class="comment">//信号声明</span></span><br><span class="line"> <span class="function"><span class="keyword">void</span> <span class="title">mySignal</span><span class="params">()</span></span>;</span><br><span class="line"><span class="keyword">public</span> slots:   <span class="comment">//槽函数声明</span></span><br><span class="line"> <span class="function"><span class="keyword">void</span> <span class="title">mySlot</span><span class="params">()</span></span>;</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">//槽函数实现：</span></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">MainWindow::mySlot</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span>&#123; <span class="comment">//发送信号：</span></span><br><span class="line">	<span class="function">emit <span class="title">mySignal</span><span class="params">()</span></span>;</span><br><span class="line">&#125; </span><br><span class="line"><span class="comment">//信号槽：1.传统写法</span></span><br><span class="line">  <span class="built_in">connect</span>(&amp;s,&amp;subwidget::<span class="built_in">mySignal</span>(),<span class="keyword">this</span>,&amp;subwidget::<span class="built_in">mySlot</span>());</span><br><span class="line"><span class="comment">//信号槽：2.用Qt4信号连接  SIGNAL() 和SLOTS(); </span></span><br><span class="line"><span class="comment">/*	</span></span><br><span class="line"><span class="comment">  	注意：SIGNAKL()需和SLOT()组合使用，</span></span><br><span class="line"><span class="comment">  		信号需要在定义时用 signals：关键字声明，槽函数需要用public slots:关键字声明</span></span><br><span class="line"><span class="comment">  	缺点:SIGNAL() 和SLOTS() 将函数名字转换成字符串，不进行错误检查</span></span><br><span class="line"><span class="comment">*/</span> </span><br><span class="line">  <span class="built_in">connect</span>(&amp;s,<span class="built_in">SIGNAL</span>(<span class="built_in">mySignal</span>()),<span class="keyword">this</span>,<span class="built_in">SLOT</span>(<span class="built_in">mySlot</span>()));</span><br><span class="line"><span class="comment">//信号槽：3. Qt5 Lambda表达式 匿名函数对象</span></span><br><span class="line">  <span class="comment">// C++11的新特性 使用需要在项目文件 pro中加入 CONFIG += C++11；</span></span><br><span class="line">  <span class="comment">// Qt配合信号一起使用</span></span><br><span class="line"> <span class="built_in">connect</span>(&amp;s,&amp;subwidget::<span class="built_in">mySignal</span>(),</span><br><span class="line">          [=]() <span class="keyword">mutable</span></span><br><span class="line">          &#123;</span><br><span class="line">              i+=<span class="number">10</span>;</span><br><span class="line">              s-&gt;<span class="built_in">setText</span>(<span class="string">&quot;Lambda&quot;</span>);</span><br><span class="line">              s-&gt;<span class="built_in">move</span>(i,i); </span><br><span class="line">          &#125;</span><br><span class="line">  );</span><br><span class="line"> <span class="comment">// =    :把外部所有变量,类，以值传递方式传进来值传递方式默认为只读，不可修改</span></span><br><span class="line">          <span class="comment">// this :把类中所有变量，以值传递方式传进来值传递方式</span></span><br><span class="line">          <span class="comment">// &amp;    :把外部所有局部变量引用</span></span><br><span class="line">          <span class="comment">// mutab :将默认只读，改为可读可写</span></span><br></pre></td></tr></table></figure>

<h3 id="3-3-自定义信号与槽-有参数"><a href="#3-3-自定义信号与槽-有参数" class="headerlink" title="3.3 自定义信号与槽(有参数)"></a>3.3 自定义信号与槽(有参数)</h3><figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//信号：</span></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">mySignal</span><span class="params">(<span class="keyword">int</span> a, <span class="keyword">float</span> b)</span></span>;</span><br><span class="line"><span class="comment">//槽：</span></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">MainWindow::mySlot</span><span class="params">(<span class="keyword">int</span> b)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	<span class="built_in">qDebug</span>()&lt;&lt; b;</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">//信号槽：</span></span><br><span class="line"><span class="built_in">connect</span>(<span class="keyword">this</span>, <span class="built_in">SIGNAL</span>(<span class="built_in">mySignal</span>(<span class="keyword">int</span>, <span class="keyword">float</span>)), <span class="keyword">this</span>, <span class="built_in">SLOT</span>(<span class="built_in">mySLot</span>(<span class="keyword">int</span>)));</span><br><span class="line"><span class="comment">//发送信号：</span></span><br><span class="line"><span class="function">emit <span class="title">mySignal</span><span class="params">(<span class="number">5</span>, <span class="number">2.2</span>)</span></span></span><br><span class="line"><span class="function"></span></span><br></pre></td></tr></table></figure>

<h3 id="3-4-自定义信号与槽-有参数，函数重载"><a href="#3-4-自定义信号与槽-有参数，函数重载" class="headerlink" title="3.4 自定义信号与槽(有参数，函数重载)"></a>3.4 自定义信号与槽(有参数，函数重载)</h3><figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&quot;mainwidget.h&quot;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;QPushButton&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;QDebug&gt;</span></span></span><br><span class="line">MainWidget::<span class="built_in">MainWidget</span>(QWidget *parent)</span><br><span class="line">  : <span class="built_in">QWidget</span>(parent)</span><br><span class="line">&#123;</span><br><span class="line">  <span class="comment">//当信号发生重载时 my_signal(),my_signal(int,QString,QString) 调用my_signal需要用以下方法</span></span><br><span class="line">  <span class="comment">// 1.用函数指针</span></span><br><span class="line">  <span class="built_in"><span class="keyword">void</span></span> (SubWidget:: *none_para_signal)() = &amp;SubWidget::my_signal;</span><br><span class="line">  <span class="built_in"><span class="keyword">void</span></span> (SubWidget:: *para_signal)(<span class="keyword">int</span>,QString,QString) = &amp;SubWidget::my_signal;</span><br><span class="line">  <span class="built_in">connect</span>(&amp;s,none_para_signal,<span class="keyword">this</span>,&amp;MainWidget::s_b_slot);</span><br><span class="line">  <span class="built_in">connect</span>(&amp;s,para_signal,<span class="keyword">this</span>,&amp;MainWidget::my_slot);</span><br><span class="line">  <span class="comment">// 2.用Qt4信号连接  SIGNAL() 和SLOTS(); SIGNAKL()需和SLOT()组合使用</span></span><br><span class="line">  <span class="comment">// 缺点 SIGNAL() 和SLOTS() 将函数名字转换成字符串，不进行错误检查</span></span><br><span class="line">  <span class="built_in">connect</span>(&amp;s,<span class="built_in">SIGNAL</span>(<span class="built_in">my_signal</span>()),<span class="keyword">this</span>,<span class="built_in">SLOT</span>(<span class="built_in">s_b_slot</span>()));</span><br><span class="line">  <span class="built_in">connect</span>(&amp;s,<span class="built_in">SIGNAL</span>(<span class="built_in">my_signal</span>(<span class="keyword">int</span>,QString,QString)),<span class="keyword">this</span>,<span class="built_in">SLOT</span>(<span class="built_in">my_slot</span>(<span class="keyword">int</span>,QString,QString)));</span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">MainWidget::s_b_slot</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">  <span class="keyword">this</span>-&gt;<span class="built_in">show</span>();</span><br><span class="line">  s.<span class="built_in">hide</span>();</span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">MainWidget::my_slot</span><span class="params">(<span class="keyword">int</span> a,QString str1,QString str2)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">  <span class="keyword">this</span>-&gt;<span class="built_in">setWindowTitle</span>(str1);</span><br><span class="line">  m_b-&gt;<span class="built_in">setText</span>(str2);</span><br><span class="line">  <span class="built_in">qDebug</span>()&lt;&lt;a&lt;&lt; str1 &lt;&lt;str2;</span><br><span class="line">&#125;</span><br><span class="line">MainWidget::~<span class="built_in">MainWidget</span>()</span><br><span class="line">&#123;</span><br><span class="line"></span><br><span class="line">&#125;</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h3 id="3-5-Lambda表达式-★★★"><a href="#3-5-Lambda表达式-★★★" class="headerlink" title="3.5 Lambda表达式  ★★★"></a>3.5 Lambda表达式  ★★★</h3><p>C++11中的Lambda表达式<strong>用于定义并创建匿名的函数对象</strong>，以简化编程工作。</p>
<p><img src="https://gitee.com/hyw-zero/blogimage/raw/master/img/lambda.png" alt="lambda"></p>
<p>**[ **函数对象参数 **] ** **( ** 操作符重载函数参数  **) mutable **或 <strong>exception</strong> -&gt; 返回值 {函数体}</p>
<p><strong>① 函数对象参数；</strong></p>
<p><strong>[]<strong>，标识一个</strong>Lambda的开始</strong>，这部分必须存在，<strong>不能省略</strong>。函数对象参数是传递给编译器自动生成的函数对象类的构造函数的。函数对象参数只能使用那些到定义Lambda为止时Lambda所在作用范围内可见的局部变量（包括Lambda所在类的this）。函数对象参数有以下形式：</p>
<ul>
<li>空。没有使用任何函数对象参数。</li>
</ul>
<ul>
<li><p><strong>=</strong> 函数体内可以使用Lambda所在作用范围内所有可见的局部变量（包括Lambda所在类的this），并且是<strong>值传递方式</strong>（相当于编译器自动为我们按值传递了所有局部变量）。</p>
</li>
<li><p><strong>&amp;</strong> 函数体内可以使用Lambda所在作用范围内所有可见的局部变量（包括Lambda所在类的this），并且是<strong>引用传递方式</strong>（相当于编译器自动为我们按引用传递了所有局部变量）。</p>
</li>
<li><p><strong>this</strong> 函数体内可以使用Lambda所在类中的成员变量。</p>
</li>
<li><p><strong>a</strong>  将a按值进行传递。按值进行传递时，函数体内不能修改传递进来的a的拷贝，因为默认情况下函数是const的。要修改传递进来的a的拷贝，可以添加mutable修饰符。</p>
</li>
<li><p><strong>&amp;a</strong>  将a按引用进行传递。</p>
</li>
<li><p><strong>a, &amp;b</strong>  将a按值进行传递，b按引用进行传递。</p>
</li>
<li><p><strong>=，&amp;a, &amp;b</strong>  除a和b按引用进行传递外，其他参数都按值进行传递。</p>
</li>
<li><p><strong>&amp;, a, b</strong>  除a和b按值进行传递外，其他参数都按引用进行传递。</p>
</li>
</ul>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">int</span> m = <span class="number">0</span>, n = <span class="number">0</span>;</span><br><span class="line">    [=] (<span class="keyword">int</span> a) <span class="keyword">mutable</span> &#123; m = ++n + a; &#125;;</span><br><span class="line">    [&amp;] (<span class="keyword">int</span> a) &#123; m = ++n + a; &#125;(<span class="number">4</span>);</span><br><span class="line">    [=,&amp;m] (<span class="keyword">int</span> a) <span class="keyword">mutable</span> &#123; m = ++n + a; &#125;;</span><br><span class="line">    [&amp;,m] (<span class="keyword">int</span> a) <span class="keyword">mutable</span> &#123; m = ++n + a; &#125;;</span><br><span class="line">    [m,n] (<span class="keyword">int</span> a) <span class="keyword">mutable</span> &#123; m = ++n + a; &#125;;</span><br><span class="line">    [&amp;m,&amp;n] (<span class="keyword">int</span> a) &#123; m = ++n + a; &#125;;</span><br></pre></td></tr></table></figure>

<p><strong>② 操作符重载函数参数；</strong></p>
<p>标识重载的()操作符的参数，没有参数时，这部分可以省略。参数可以通过按值（如：(a,b)）和按引用（如：(&amp;a,&amp;b)）两种方式进行传递。</p>
<p><strong>③ 可修改标示符；</strong></p>
<p>mutable声明，这部分可以省略。按值传递函数对象参数时，加上mutable修饰符后，可以修改按值传递进来的拷贝（注意是能修改拷贝，而不是值本身）。</p>
<p><strong>④ 错误抛出标示符；</strong></p>
<p>exception声明，这部分也可以省略。exception声明用于指定函数抛出的异常，如抛出整数类型的异常，可以使用throw(int)</p>
<p><strong>⑤ 函数返回值；</strong></p>
<p>**-&gt;**返回值类型，标识函数返回值的类型，当返回值为void，或者函数体中只有一处return的地方（此时编译器可以自动推断出返回值类型）时，这部分可以省略。</p>
<p><strong>⑥ 是函数体；</strong></p>
<p>  {}，标识函数的实现，这部分不能省略，但函数体可以为空。</p>
<blockquote>
<p><strong>自定义信号槽需要注意的事项</strong></p>
<ul>
<li>发送者和接收者都需要是QObject的子类（当然，槽函数是全局函数、Lambda 表达式等无需接收者的时候除外）；</li>
<li>使用 signals 标记信号函数，信号是一个函数声明，返回 void，不需要实现函数代码；</li>
<li>槽函数是普通的成员函数，作为成员函数，会受到 public、private、protected 的影响；</li>
<li> 使用 emit 在恰当的位置发送信号；</li>
<li>使用QObject::connect()函数连接信号和槽。</li>
<li>任何成员函数、static 函数、全局函数和 Lambda 表达式都可以作为槽函数</li>
</ul>
<p><strong>信号槽的更多用法</strong></p>
<ul>
<li>一个信号可以和多个槽相连</li>
</ul>
<p>如果是这种情况，这些槽会一个接一个的被调用，但是它们的<strong>调用顺序是不确定的。</strong></p>
<ul>
<li>多个信号可以连接到一个槽</li>
</ul>
<p>只要任意一个信号发出，这个槽就会被调用。</p>
<ul>
<li>一个信号可以连接到另外的一个信号</li>
</ul>
<p>当第一个信号发出时，第二个信号被发出。除此之外，这种信号-信号的形式和信号-槽的形式没有什么区别。</p>
<ul>
<li>槽可以被取消链接</li>
</ul>
<p>这种情况并不经常出现，因为<strong>当一个对象delete之后，Qt自动取消所有连接到这个对象上面的槽</strong>。</p>
</blockquote>

    </div>

    
    
    
	<div>
		
			<div>
	
		<div style="text-align:center;color: #ccc;font-size:16px;">---------------------------------------本文结束<i class="fa fa-paw"></i>感谢您的阅读---------------------------------------</div>
	
</div>
		
	</div>
	<div>
		
			
<div class="my_post_copyright">
<script src="//cdn.bootcss.com/clipboard.js/1.5.10/clipboard.min.js"></script>
<!-- JS库 sweetalert 可修改路径 -->
<script src="https://cdn.bootcss.com/jquery/2.0.0/jquery.min.js"></script>
<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
<p><span>本文标题:</span><a href="/2019/01/06/Qt%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0%E4%B9%8B%E4%BF%A1%E5%8F%B7%E4%B8%8E%E6%A7%BD/">Qt学习笔记之信号与槽</a></p>
<!--
<p><span>文章作者:</span><a href="/" title="访问  的个人博客"></a></p>
-->
<p><span>发布时间:</span>2019年01月05日 - 22:10</p>
<p><span>最后更新:</span>2021年08月22日 - 09:52</p>
<p><span>原始链接:</span><a href="/2019/01/06/Qt%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0%E4%B9%8B%E4%BF%A1%E5%8F%B7%E4%B8%8E%E6%A7%BD/" title="Qt学习笔记之信号与槽">https://hyw-zero.github.io/2019/01/06/Qt%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0%E4%B9%8B%E4%BF%A1%E5%8F%B7%E4%B8%8E%E6%A7%BD/</a>
<span class="copy-path" title="点击复制文章链接"><i class="fa fa-clipboard" data-clipboard-text="https://hyw-zero.github.io/2019/01/06/Qt%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0%E4%B9%8B%E4%BF%A1%E5%8F%B7%E4%B8%8E%E6%A7%BD/" aria-label="复制成功！"></i></span>
</p>
<p><span>许可协议:</span><i class="fa fa-creative-commons"></i> <a rel="license" href="https://creativecommons.org/licenses/by-nc-nd/4.0/" target="_blank" title="Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0)">署名-非商业性使用-禁止演绎 4.0 国际</a> 转载请保留原文链接及作者。</p>
</div>
<script>
var clipboard = new Clipboard('.fa-clipboard');
$(".fa-clipboard").click(function(){
clipboard.on('success', function(){
swal({
title: "",
text: '复制成功',
icon: "success",
showConfirmButton: true
});
});
});
</script>

		
	</div>

    <footer class="post-footer">
          <div class="reward-container">
  <div></div>
  <button>
    赞赏
  </button>
  <div class="post-reward">
      <div>
        <img src="/images/wx.png" alt="hyw-zero 微信">
        <span>微信</span>
      </div>
      <div>
        <img src="/images/alipay.png" alt="hyw-zero 支付宝">
        <span>支付宝</span>
      </div>

  </div>
</div>

          <div class="post-tags">
              <a href="/tags/C/" rel="tag"><i class="fa fa-tag"></i>C++</a>
          </div>

        

          <div class="post-nav">
            <div class="post-nav-item">
                <a href="/2018/12/04/linux%E5%8E%8B%E7%BC%A9%E5%91%BD%E4%BB%A4/" rel="prev" title="linux命令(压缩)">
                  <i class="fa fa-chevron-left"></i> linux命令(压缩)
                </a>
            </div>
            <div class="post-nav-item">
                <a href="/2019/02/06/Qt%20%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0%E4%B9%8B%E6%95%B0%E6%8D%AE%E5%BA%93%E6%93%8D%E4%BD%9C/" rel="next" title="Qt学习笔记之数据库操作">
                  Qt学习笔记之数据库操作 <i class="fa fa-chevron-right"></i>
                </a>
            </div>
          </div>
    </footer>
  </article>
</div>






    <div class="comments" id="lv-container" data-id="city" data-uid="MTAyMC80MzU4NC8yMDEyMw=="></div>
</div>
  </main>

  <footer class="footer">
    <div class="footer-inner">


<div class="copyright">
  &copy; 2018 – 
  <span itemprop="copyrightYear">2021</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">hyw-zero</span>
</div>
<div class="busuanzi-count">
    <span class="post-meta-item" id="busuanzi_container_site_uv">
      <span class="post-meta-item-icon">
        <i class="fa fa-user"></i>
      </span>
      <span class="site-uv" title="总访客量">
        <span id="busuanzi_value_site_uv"></span>
      </span>
    </span>
    <span class="post-meta-item" id="busuanzi_container_site_pv">
      <span class="post-meta-item-icon">
        <i class="fa fa-eye"></i>
      </span>
      <span class="site-pv" title="总访问量">
        <span id="busuanzi_value_site_pv"></span>
      </span>
    </span>
</div>
<div class="theme-info">
	<i class="fa fa-edit" style="font-size:18px"></i>
	<span class="post-count">博客全站共98.2k字</span>
</div>
    </div>
  </footer>

  
  <script src="https://cdn.jsdelivr.net/npm/animejs@3.2.1/lib/anime.min.js" integrity="sha256-XL2inqUJaslATFnHdJOi9GfQ60on8Wx1C2H8DYiN1xY=" crossorigin="anonymous"></script>
<script src="/js/comments.js"></script><script src="/js/utils.js"></script><script src="/js/motion.js"></script><script src="/js/next-boot.js"></script>

  
<script src="/js/third-party/search/local-search.js"></script>



  <script class="next-config" data-name="nprogress" type="application/json">{"enable":true,"spinner":true}</script>
  <script src="/js/third-party/nprogress.js"></script>

  
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>




<script src="/js/third-party/comments/livere.js"></script>
</body>
<!-- 页面点击小红心 -->
<script type="text/javascript" src="/js/love.js"></script>
</html>

